package calao.client.ui;

public class NumberFormat 
extends Format
{

	final com.google.gwt.i18n.client.NumberFormat format;
	
	/** Default decimal format.
	 */
	public NumberFormat()
	{
		format = com.google.gwt.i18n.client.NumberFormat.getDecimalFormat();
	}

	public NumberFormat(String pattern)
	{
		format = com.google.gwt.i18n.client.NumberFormat.getFormat(pattern);
	}
			
	public String formatAsText(Object data)
	{
		Number num = (Number)data;
		return num!=null? format.format(num.doubleValue()) : "";
	}
	
	public String format(double number)
	{
		return format.format(number);
	}
	
	public boolean alignsRight()
	{
		return true;
	}
	
	public double parse(String number)
	{
		return format.parse(number);
	}
	
}
